﻿using System;


namespace BizElements.BusinessLayer
{
    /// <summary>
    /// Data and meta required to bind a business field to a <b>IBoundControl</b> control.
    /// </summary>
    public interface IBindableField
    {
        #region Properties.

        /// <summary>
        /// Name of the property that is displayed and modified in binding engine. Null is <b>not</b> allowed.
        /// </summary>
        string BindingName { get; }

        /// <summary>
        /// Caption of the bound field. <b>Nullable</b>.
        /// </summary>
        string Caption { get; }

        /// <summary>
        /// Type of the value stored in the property. Null is <b>not</b> allowed. 
        /// </summary>
        /// <remarks>Primitive .NET types should be used whenever possible. Eg. use <b>int</b> instead of
        /// <b>NullableInt32</b>.</remarks>
        Type DataType { get; }

        /// <summary>
        /// Indicates whether the field is nullable. FieldBinding engines may use special types/values to represent
        /// null-values, when the specified field <see cref="DataType"/> is not nullable.
        /// </summary>
        bool IsNullable { get; }

        /// <summary>
        /// Indicates whether the contents of the field may be modified by binding engines.
        /// </summary>
        bool IsReadOnly { get; }

        /// <summary>
        /// The list of allowed values for the field. <b>Nullable</b>. Typically used in combation with list controls.
        /// </summary>
        ICodeList CodeList { get; set; }

        /// <summary>
        /// Additional display fields that are uniquely identified by this field. <b>Nullable</b>. 
        /// Typically used by lookup controls when the bound field represents a hidden key value.
        /// </summary>
        string[] SatelliteFields { get; set; }

        /// <summary>
        /// The position of the field in the collection. 
        /// </summary>
        int Ordinal { get; set; }

        /// <summary>
        /// Detailed description of the bound field. <b>Nullable</b>.
        /// </summary>
        string Description { get; }

        /// <summary>
        /// Indicates whether the field should be hidden from view in the user interface.
        /// </summary>
        bool IsHidden { get; }

        #endregion
    }
}